package com.HelloWord;

import com.sun.org.apache.xpath.internal.operations.Mod;

/**
 * Created by onlylove on 2016/10/7.
 */
public  class HelloWord{
    public static void main(String[] args){
//        Animal dog = new Animal();
//        dog.setAnimal("小狗",6,"汪");
//        dog.showAnimal();
//        Animal cat = new Animal();
//        cat.setAnimal("小猫",3,"喵");
//        cat.showAnimal();
        //Modtest mod = new Modtest();
        //Modtest.smod();
        //String text = Modtest.text;
        //System.out.println(text);
        SubClass s = new SubClass();
        s.showString();
        s.showString("我是有形参的函数");

        String[] name = {"张三","李四","王五","陈七","吴八","黄二"};
        for (String n:name){
            System.out.println(n);
        }
        int namelen = name.length;
        System.out.println(namelen);
        String len = "我只想看一下length";
        System.out.println(len.length());

        Ren ren = new Ren();
        ren.boy();
        ren.girl();

    }
}

class Modtest {  // 构造方法和静态方法练习
    int age;
    String name;
    String address;
    static String text = "静态变量";
    Modtest(int age,String name) {
        this.age = age;
        this.name = name;
        System.out.println(age + name);
    }

    Modtest(){
        this(32,"张劲");
    }

    static void smod(){
        System.out.println("静态方法");
    }
}

class Animal {  // 创建动物类
    int num;
    String name;
    String sound;

    public void setAnimal(String setName,int setNum,String setSound){
        num = setNum;
        name = setName;
        sound = setSound;
    }

    public void showAnimal(){
        System.out.println("动物名称：" + name);
        System.out.println("叫声："+num);
        for (int i = 0; i < num; i++) {
            System.out.print(sound);
        }
        System.out.println("");
    }
}

interface sound{
    public void girl();
    public void boy();
}

class Ren implements sound{
    @Override
    public void girl(){
        System.out.println("我是女生");
    }

    @Override
    public void boy() {
        System.out.println("我是男生");
    }
}


